//
//  VersionInfoModel.swift
//  XiaoweHealthy
//
//  Created by Riven on 2022/9/6.
//

import Foundation
import HandyJSON


class VersionInfoModel: HandyJSON {
    
    /// true有新版false无新版本，只有为true时其他返回字段才有意义
    var available = false
    
    /// true强制false非强制
    var hasForce = false
    
    /// 新版本下载地址
    var downloadUrl = ""
    
    /// 新版本描述性文字
    var changeList = ""
    
    /// 新版本版本号(v1.05.01)
    var version = ""
    
    /// 文件大小
    var fileSize = 0
    
//    var signCode = ""
    
    var contentAttrText: NSAttributedString {
//        let dotString = "●"
//        let dotString = "●"
//
//        var contentArray = changeList.components(separatedBy: "\n")
//        contentArray = contentArray.compactMap({
//            var tString = $0.trimmed
//            if tString.isEmpty {
//                return nil
//            }
//
//            tString = "\(dotString) " + tString + "\n\n"
//
//            return tString
//        })
//
//        let tString = contentArray.joined(separator: "")
//        let tAttrString = NSAttributedString(string: tString).applying(attributes: [.font: AppFont.harmonyOSSans(ofSize: 12, weight: .medium), .foregroundColor: majorTextColor], toOccurrencesOf: tString).applying(attributes: [.font: AppFont.harmonyOSSans(ofSize: 8, weight: .medium), .foregroundColor: btnBgColor], toOccurrencesOf: dotString)
//
//        return tAttrString
        
        let contentTitleFont: UIFont = AppFont.harmonyOSSans(ofSize: 17, weight: .medium)
        let contentTitleText = "本次更新内容："
        
        let contentFont: UIFont = AppFont.harmonyOSSans(ofSize: 15, weight: .regular)
        
        let tText = "\(contentTitleText)\n\n\(changeList)"
        var attr = NSAttributedString(string: tText, attributes: [.font: contentFont, .foregroundColor: minorTextColor])
        attr = attr.applying(attributes: [.font: contentTitleFont, .foregroundColor: majorTextColor], toOccurrencesOf: contentTitleText)
        
        return attr
    }
    
    required init() {
        
    }
    
    func mapping(mapper: HelpingMapper) {
        
    }
    
}
